﻿<MAH:MetroWindow x:Class="WPFExcelReport.MasterWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                      xmlns:ucd="clr-namespace:ReflectionStudio.Components.UserControls;assembly=ReflectionStudio.Controls"
                      xmlns:cv="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls" 
                     xmlns:Menus="clr-namespace:WPFExcelReport;assembly=TICC_MENUDEF"
                     xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"   
                     xmlns:HR="clr-namespace:WPFExcelReport;assembly=TICC_HRSTAMM"
                        xmlns:THR="clr-namespace:WPFExcelReport;assembly=THRSTAMM"
                     xmlns:WF="clr-namespace:WPFExcelReport;assembly=TICC_WFEVENTS" 
                     xmlns:Localization="clr-namespace:Localization;assembly=Localization" 
                     xmlns:HP="clr-namespace:WPFExcelReport;assembly=HelpDocument" 
                    xmlns:MAH="http://metro.mahapps.com/winfx/xaml/controls"
                    Topmost="False"  
                    ShowTitleBar="False" 
                    FontSize="12" 
                    WindowState="Maximized"
                     Name="TV"
                    > 
    <MAH:MetroWindow.Resources>
        <DataTemplate x:Key="ThemeItemTemplate">
            <Border ToolTip="{Binding Name}">
                <StackPanel Orientation="Vertical">
                    <Image Source="{Binding Image}" Stretch="None"/>
                    <TextBlock Text="{Binding Path=Name, Mode=OneWay}" FontSize="14" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </StackPanel>
            </Border>
        </DataTemplate>
        <Ellipse x:Key="AppThemeMenuIcon"
                     x:Shared="False"
                     Width="16"
                     Height="16"
                     StrokeThickness="1"
                     Stroke="{Binding BorderColorBrush, Mode=OneWay}"
                     Fill="{Binding ColorBrush, Mode=OneWay}" />
        <Ellipse x:Key="AccentMenuIcon"
                     x:Shared="False"
                     Width="16"
                     Height="16"
                     Fill="{Binding ColorBrush, Mode=OneWay}" />
        <Style x:Key="AppThemeMenuItemStyle"
                   TargetType="{x:Type MenuItem}"
                   BasedOn="{StaticResource MetroMenuItem}">
            <Setter Property="Command"
                        Value="{Binding ChangeAccentCommand}" />
            <Setter Property="Icon"
                        Value="{StaticResource AppThemeMenuIcon}" />
            <Setter Property="Header"
                        Value="{Binding Name, Mode=OneWay}" />
        </Style>

        <Style x:Key="AccentColorMenuItemStyle"
                   TargetType="{x:Type MenuItem}"
                   BasedOn="{StaticResource MetroMenuItem}">
            <Setter Property="Command"
                        Value="{Binding ChangeAccentCommand}" />
            <Setter Property="Icon"
                        Value="{StaticResource AccentMenuIcon}" />
            <Setter Property="Header"
                        Value="{Binding Name, Mode=OneWay}" />
        </Style>

        <cv:BoolToVisibilityConverter  x:Key="bv"/>
        <cv:NOTBoolToVisibilityConverter  x:Key="nbv"/>
        <cv:String2ColorConverter x:Key="sc"/>
        <cv:NOTConverter  x:Key="not"/>
    </MAH:MetroWindow.Resources>
    <MAH:MetroWindow.Flyouts>
        <MAH:FlyoutsControl x:Name="flyoutsControl">
            <MAH:Flyout Header="待完成任务" 
                        Position="Left"
                        IsModal="True"
                        AnimateOpacity="True"
                        IsOpen="{Binding IsWFFixed,ElementName=cWF,Converter={StaticResource not}}"
                        Theme="Adapt">
                <WF:TWFUSER Name="cWF"
                    CUSER="{Binding CUSER,ElementName=TV}"
                            IsCanLoad="{Binding IsWFMSG,ElementName=TV}"/>
            </MAH:Flyout>
            <MAH:Flyout Header="待完成任务" 
                        Position="Top"
                        IsModal="True"
                        AnimateOpacity="True"
                        IsOpen="{Binding IsNewWF}" 
                       
                        Theme="Adapt">
                <WF:TWFNEW Name="cWFN"
                           IsMasterFromMV="True"
                    CUSER="{Binding CUSER,ElementName=TV}"
                            IsCanLoad="{Binding IsWFMSG,ElementName=TV}"/>
            </MAH:Flyout>
        </MAH:FlyoutsControl>
    </MAH:MetroWindow.Flyouts>
    <Grid x:Name="Maingrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"
              Visibility="{Binding IsSingleRun,ElementName=TV,Converter={StaticResource nbv}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <WrapPanel Grid.Column="1" HorizontalAlignment="Left">
                <TextBlock Text="{Binding IntexAccount}" Width="60"/>
                <Menu  Margin="5,0,0,0" VerticalAlignment="Top" Visibility="Collapsed"
                  HorizontalAlignment="Left">
                    <MenuItem Header="{Binding AppThemeText}" 
                          ItemsSource="{Binding AppThemes, Mode=OneWay}"
                          ItemContainerStyle="{StaticResource AppThemeMenuItemStyle}" />
                    <MenuItem Header="{Binding AccentColorText}"  Visibility="Collapsed"
                          ItemsSource="{Binding AccentColors, Mode=OneWay}"
                          ItemContainerStyle="{StaticResource AccentColorMenuItemStyle}" />
                </Menu>
                <Menus:TMUCLIENT  x:Name="clientmenu"
                                  ORDERNUM="ITXRPTC"
                                  />
                <Button   Click="SetMasterCommand"  Margin="5,0,0,0" Width="24" Height="20" VerticalAlignment="Top">
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Extend.png" />
                    </Button.Background>
                </Button>
                <Button   Click="SetLogCommand" Height="20" Margin="5,0,0,0" Width="24" VerticalAlignment="Top">
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/help.png" />
                    </Button.Background>
                </Button>
                <Button   Click="CloseWindowCommand" Height="20" Margin="5,0,0,0" Width="24" VerticalAlignment="Top" >
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Delete.png" />
                    </Button.Background>
                </Button>
                <Button   Click="SetLogOnCommand" Height="20" Margin="5,0,0,0" Width="24" VerticalAlignment="Top">
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/User.png" />
                    </Button.Background>
                </Button>
                <Button   Click="DBQueryCommand" Height="20" Margin="5,0,0,0" Width="Auto" Content="SQL" Foreground="Green" VerticalAlignment="Top">

                </Button>
                <Button   Click="ITXSetUp" Height="20" Margin="5,0,0,0" Width="24" VerticalAlignment="Top">
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/build.png" />
                    </Button.Background>
                </Button>
                <Button   Click="SDKEYSetUp" Content="K" Height="20" Margin="5,0,0,0" Width="24" 
                          VerticalAlignment="Top">


                </Button>
                <Button   Click="HelpCommand" Height="20" Margin="5,0,0,0" Width="24" VerticalAlignment="Top">
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/arrowextend.png" />
                    </Button.Background>
                </Button>
                <WrapPanel  VerticalAlignment="Top">
                    <Button Click="ENModeCommand" Height="20" Margin="5,0,0,0" 
                            Visibility="{Binding IsCN,Converter={StaticResource bv}}"
                            Content="中" Foreground="Red" Width="Auto"/>
                    <Button Click="CNModeCommand" Height="20" Margin="5,0,0,0" VerticalAlignment="Top"
                             Visibility="{Binding IsEN,Converter={StaticResource bv}}"
                            Content="EN" Foreground="Green"  Width="Auto" />
                </WrapPanel>

                <WrapPanel Visibility="{Binding IsTST,Converter={StaticResource bv}}" VerticalAlignment="Top">
                    <Button Click="TSModeCommand" Height="20" Margin="5,0,0,0" 
                            Visibility="{Binding IsTS,Converter={StaticResource bv}}"
                            Content="TS" Foreground="Red" Width="Auto"/>
                    <Button Click="TMModeCommand" Height="20" Margin="5,0,0,0" VerticalAlignment="Top"
                             Visibility="{Binding IsTS,Converter={StaticResource nbv}}"
                            Content="TM" Foreground="Green"  Width="Auto" />
                </WrapPanel>
                <WrapPanel  VerticalAlignment="Top">
                    <Button Click="ZMModeCommand" Height="20" Margin="5,0,0,0" 
                            Visibility="{Binding IsZM,Converter={StaticResource bv}}"
                            Content="+" Foreground="Red" Width="Auto"/>
                    <Button Click="ZMModeCommand" Height="20" Margin="5,0,0,0" VerticalAlignment="Top"
                             Visibility="{Binding IsZM,Converter={StaticResource nbv}}"
                            Content="-" Foreground="Green"  Width="Auto" />
                    <Button Click="WFModeCommand" Height="20" Margin="5,0,0,0" VerticalAlignment="Top" 
                            Content="业" Foreground="Green" Background="Yellow"  Width="Auto" /> 
                    <THR:THR20 ORDERNUM="{Binding CUSER,ElementName=TV}" Margin="10,0,0,0"/>
                </WrapPanel>
                <WF:TSTATUS Margin="10,0,0,0" Grid.Row="0" VerticalAlignment="Top"  
                            MSGTYP="{Binding MSGTYP,ElementName=cLog}"
                            INFO="{Binding INFO,ElementName=cLog}" />
            </WrapPanel>
        </Grid>
        <HR:TLOGIN  Grid.Row="1" Grid.Column="0"  Grid.ColumnSpan="3"
                    Name="cLogIn"
                    Visibility="{Binding IsLogOn,ElementName=TV,Converter={StaticResource ResourceKey=nbv}}"  
                    IsLogOn="{Binding IsLogOn,ElementName=TV}"/>
        <Grid  Name="MainContent" Grid.Row="1" Grid.Column="1"  Grid.ColumnSpan="1" 
               >
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <WrapPanel>
               
            </WrapPanel>
        </Grid>
        <Grid  Grid.Row="1" Grid.Column="1"  Grid.ColumnSpan="1" 
               Visibility="{Binding IsLogOn,ElementName=TV,Converter={StaticResource ResourceKey=bv}}"  >
            
            <MAH:MetroTabControl   x:Name="MainTab" SelectedIndex="1" 
                                       Visibility="{Binding IsSingleRun,ElementName=TV,Converter={StaticResource nbv}}">
                    <MAH:MetroTabItem Header="{Binding LogText}" 
                             Tag="Log"
                              CloseTabCommand="{Binding CloseTabCommand}"
                                   CloseButtonEnabled="False"
                                   Visibility="{Binding IsShowLog,Converter={StaticResource bv}}">
                        <WF:TWFLOG Name="cLog" />
                    </MAH:MetroTabItem>
                    <MAH:MetroTabItem Header="{Binding MenuText}" Tag="Menu" CloseButtonEnabled="False">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="1*"></RowDefinition>
                            </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="1*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                       
                        <ex:AniScrollViewer Grid.Row="0" Grid.Column="1"   
                                        HorizontalScrollBarVisibility="Visible" 
                                        VerticalScrollBarVisibility="Visible">
                                <Menus:TMENU  x:Name="MainMenu"
                                      ORDERNUM="{Binding KEY,ElementName=cLogIn}"
                                     IsMenuTree="{Binding IsMenuTree,ElementName=TV}"
                                      ActiveDoc="{Binding ActiveDoc,ElementName=TV}"
                                      />
                            </ex:AniScrollViewer>
                        </Grid>
                    </MAH:MetroTabItem>
                </MAH:MetroTabControl>  
        </Grid>  
    
        <Expander IsExpanded="{Binding IsHelp,ElementName=TV}" 
                  Grid.Row="0" Grid.RowSpan="9999"
                  Grid.Column="1"
                  ExpandDirection="Right" 
                  Visibility="{Binding IsHelp,ElementName=TV,Converter={StaticResource bv}}" >
            <HP:THELP
                Name="cHelp"
                IsHelp="{Binding IsHelp,ElementName=TV}" 
                EXAUF="{Binding ActiveDoc,ElementName=TV}"
                      />
        </Expander>
    </Grid>
</MAH:MetroWindow>
